package com.mike.billingserver.handler;

import common.lib.core.ResultVO;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author xiaozefeng
 * @date 12/12/18 1:40 PM
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ResultVO handleException(HttpServletRequest request, Exception e) {
        log.error("error request url :{}", request.getRequestURI());
        log.error(e.getMessage(), e);
        return ResultVO.error(e.getMessage());
    }
}
